package org.jetnuke.modules.admin.stories;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.ActionForward;
import org.jetnuke.common.IAction;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IModuleInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.DataAccessDriver;
import org.jetnuke.entities.Stories;
import org.jetnuke.util.JetUtil;

public class UpdateStory implements IAction {
int id;String subject, notes, story,story_ext;
int topic; int cat;
public void setNotes(String notes) {
	this.notes = notes;
}
public void setStory(String story) {
	this.story = story;
}
public void setStory_ext(String story_ext) {
	this.story_ext = story_ext;
}
public void setSubject(String subject) {
	this.subject = subject;
}
public void setId(int id) {
	this.id = id;
}
	/* (non-Javadoc)
	 * @see org.jetnuke.common.IAction#exec(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.VelocityContext, org.jetnuke.common.IModuleInfo, java.lang.String, org.jetnuke.common.IUserInfo, org.jetnuke.common.IAdminInfo)
	 */
	public ActionForward exec(HttpServletRequest request,
			HttpServletResponse response, VelocityContext vc, IModuleInfo info,
			String op, IUserInfo ui, IAdminInfo ai) throws Exception {
		if(ai==null || ai.IsSuperUser()==false)
			return null;
		Stories stories=DataAccessDriver.getInst().newStoriesDAO().retrieveByPK(id);
		stories.setHOMETEXT(story);
		stories.setBODYTEXT(story_ext);
		stories.setNOTES(notes);
		stories.setCATID(cat);
		stories.setTOPIC(topic);
		
		DataAccessDriver.getInst().newStoriesDAO().update(stories);
		JetUtil.redirect(vc,response,request.getContextPath()+"/do/news/story?id="+id);
		return null;
	}

/**
 * @param cat The cat to set.
 */
public void setCat(int cat) {
	this.cat = cat;
}
/**
 * @param topic The topic to set.
 */
public void setTopic(int topic) {
	this.topic = topic;
}
}
